﻿using System;
using System.Net;
using System.Threading;

namespace HslCommunication.Core
{
	/// <summary>
	/// 单个的监控文件对象，用来监控客户端的信息以及上传下载的速度
	/// </summary>
	// Token: 0x02000117 RID: 279
	public class MqttFileMonitorItem
	{
		/// <summary>
		/// 实例化一个默认的对象
		/// </summary>
		// Token: 0x060017F3 RID: 6131 RVA: 0x0007CC54 File Offset: 0x0007AE54
		public MqttFileMonitorItem()
		{
			this.StartTime = DateTime.Now;
			this.LastUpdateTime = DateTime.Now;
			this.UniqueId = Interlocked.Increment(ref MqttFileMonitorItem.uniqueIdCreate);
		}

		/// <summary>
		/// 当前对象的唯一ID信息
		/// </summary>
		// Token: 0x17000526 RID: 1318
		// (get) Token: 0x060017F4 RID: 6132 RVA: 0x0007CC87 File Offset: 0x0007AE87
		// (set) Token: 0x060017F5 RID: 6133 RVA: 0x0007CC8F File Offset: 0x0007AE8F
		public long UniqueId { get; private set; }

		/// <summary>
		/// 当前对象的远程的IP及端口
		/// </summary>
		// Token: 0x17000527 RID: 1319
		// (get) Token: 0x060017F6 RID: 6134 RVA: 0x0007CC98 File Offset: 0x0007AE98
		// (set) Token: 0x060017F7 RID: 6135 RVA: 0x0007CCA0 File Offset: 0x0007AEA0
		public IPEndPoint EndPoint { get; set; }

		/// <summary>
		/// 当前对象的客户端ID
		/// </summary>
		// Token: 0x17000528 RID: 1320
		// (get) Token: 0x060017F8 RID: 6136 RVA: 0x0007CCA9 File Offset: 0x0007AEA9
		// (set) Token: 0x060017F9 RID: 6137 RVA: 0x0007CCB1 File Offset: 0x0007AEB1
		public string ClientId { get; set; }

		/// <summary>
		/// 当前对象的客户端用户名
		/// </summary>
		// Token: 0x17000529 RID: 1321
		// (get) Token: 0x060017FA RID: 6138 RVA: 0x0007CCBA File Offset: 0x0007AEBA
		// (set) Token: 0x060017FB RID: 6139 RVA: 0x0007CCC2 File Offset: 0x0007AEC2
		public string UserName { get; set; }

		/// <summary>
		/// 当前的操作，Upload是上传，Download是下载
		/// </summary>
		// Token: 0x1700052A RID: 1322
		// (get) Token: 0x060017FC RID: 6140 RVA: 0x0007CCCB File Offset: 0x0007AECB
		// (set) Token: 0x060017FD RID: 6141 RVA: 0x0007CCD3 File Offset: 0x0007AED3
		public string Operate { get; set; }

		/// <summary>
		/// 当前的操作的目录信息
		/// </summary>
		// Token: 0x1700052B RID: 1323
		// (get) Token: 0x060017FE RID: 6142 RVA: 0x0007CCDC File Offset: 0x0007AEDC
		// (set) Token: 0x060017FF RID: 6143 RVA: 0x0007CCE4 File Offset: 0x0007AEE4
		public string Groups { get; set; }

		/// <summary>
		/// 当前操作的文件名
		/// </summary>
		// Token: 0x1700052C RID: 1324
		// (get) Token: 0x06001800 RID: 6144 RVA: 0x0007CCED File Offset: 0x0007AEED
		// (set) Token: 0x06001801 RID: 6145 RVA: 0x0007CCF5 File Offset: 0x0007AEF5
		public string FileName { get; set; }

		/// <summary>
		/// 上传或下载的速度
		/// </summary>
		// Token: 0x1700052D RID: 1325
		// (get) Token: 0x06001802 RID: 6146 RVA: 0x0007CCFE File Offset: 0x0007AEFE
		// (set) Token: 0x06001803 RID: 6147 RVA: 0x0007CD06 File Offset: 0x0007AF06
		public long SpeedSecond { get; set; }

		/// <summary>
		/// 当前操作的起始时间
		/// </summary>
		// Token: 0x1700052E RID: 1326
		// (get) Token: 0x06001804 RID: 6148 RVA: 0x0007CD0F File Offset: 0x0007AF0F
		// (set) Token: 0x06001805 RID: 6149 RVA: 0x0007CD17 File Offset: 0x0007AF17
		public DateTime StartTime { get; set; }

		/// <summary>
		/// 最后一次更新数据的时间
		/// </summary>
		// Token: 0x1700052F RID: 1327
		// (get) Token: 0x06001806 RID: 6150 RVA: 0x0007CD20 File Offset: 0x0007AF20
		// (set) Token: 0x06001807 RID: 6151 RVA: 0x0007CD28 File Offset: 0x0007AF28
		public DateTime LastUpdateTime { get; set; }

		/// <summary>
		/// 文件的总大小
		/// </summary>
		// Token: 0x17000530 RID: 1328
		// (get) Token: 0x06001808 RID: 6152 RVA: 0x0007CD31 File Offset: 0x0007AF31
		// (set) Token: 0x06001809 RID: 6153 RVA: 0x0007CD39 File Offset: 0x0007AF39
		public long TotalSize { get; set; }

		/// <summary>
		/// 上一次的更新数据时的进度信息
		/// </summary>
		// Token: 0x17000531 RID: 1329
		// (get) Token: 0x0600180A RID: 6154 RVA: 0x0007CD42 File Offset: 0x0007AF42
		// (set) Token: 0x0600180B RID: 6155 RVA: 0x0007CD4A File Offset: 0x0007AF4A
		public long LastUpdateProgress { get; set; }

		/// <summary>
		/// 更新当前的文件的状态
		/// </summary>
		/// <param name="progress">当前的进度信息</param>
		/// <param name="total">当前的总大小</param>
		// Token: 0x0600180C RID: 6156 RVA: 0x0007CD54 File Offset: 0x0007AF54
		public void UpdateProgress(long progress, long total)
		{
			this.TotalSize = total;
			TimeSpan timeSpan = DateTime.Now - this.LastUpdateTime;
			bool flag = timeSpan.TotalSeconds >= 0.2;
			if (flag)
			{
				long num = progress - this.LastUpdateProgress;
				bool flag2 = num <= 0L;
				if (flag2)
				{
					this.SpeedSecond = 0L;
				}
				else
				{
					this.SpeedSecond = (long)((double)num / timeSpan.TotalSeconds);
					this.LastUpdateTime = DateTime.Now;
					this.LastUpdateProgress = progress;
				}
			}
		}

		// Token: 0x0400055D RID: 1373
		private static long uniqueIdCreate;
	}
}
